<template>
  <cloudPage :isLoading="info == null">
    <cloudHeader slot="gHeader">
      <view class="grace-header-body">
        <!-- 返回按钮 -->
        <view
          class="grace-header-icons grace-icons icon-arrow-left"
          @tap.stop="handleNavBack"
        ></view>
        <!-- 中间内容 -->
        <view class="grace-header-content-noflex grace-text-center font-32">
          {{ $t("common.title.detailed") }}
        </view>
        <!-- 右侧按钮 -->
        <view class="icons grace-icons" style="font-size: 38rpx"></view>
      </view>
    </cloudHeader>
    <view class="gbody main" v-if="info != null">
      <view class="detailed">
        <view class="header">
          <view class="title">{{ info.value.title }}</view>
          <view class="footer">
            <view class="label">{{ $t("common.title.announcement") }}</view>
            <view class="time">
              {{ info.updated_at | moment("YYYY-MM-DD HH:mm:ss") }}
            </view>
          </view>
        </view>
        <view class="body">
          <cloudHtml :html="info.value.content"></cloudHtml>
        </view>
      </view>
    </view>
  </cloudPage>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {
      id: null,
      info: null,
    };
  },
  async onLoad({ id }) {
    if (!id) {
      this.handleNavTo({ url: "/pages/announcement/index" });
      return;
    }
    this.id = id;
    let info = await this.getAnnouncementById(id);
    this.info = info;
  },
  methods: {
    ...mapActions("announcement", ["getAnnouncementById"]),
  },
};
</script>

<style scoped>
.main {
  height: 100vh;
  background-color: #121624;
}
.detailed {
  padding: 0rpx 20rpx;
}
.header {
  padding: 20rpx 0rpx;
  border-bottom: 1rpx solid rgba(255, 255, 255, 0.1);
}
.header .title {
  height: 48rpx;
  font-size: 34rpx;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 48rpx;
  margin-bottom: 24rpx;
}
.header .footer {
  display: flex;
  align-items: center;
}
.header .footer .label {
  min-width: 86rpx;
  height: 40rpx;
  line-height: 40rpx;
  background-image: url("/static/mf/home/announce_label.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 10rpx;
  text-align: center;
  color: #fee096;
  font-size: 22rpx;
  padding: 0 10rpx;
  box-sizing: border-box;
}
.header .footer .time {
  font-size: 24rpx;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 20rpx;
}
.body {
  padding-top: 30rpx;
  text-indent: 1rem;
  color: rgba(255, 255, 255, 0.7);
}
</style>
